﻿using System;
using System.ComponentModel;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using VisionCloud.Core.Model.Enums;
using VisionCloud.Core.Model.Sys;

namespace VisionCloud.Core.Model.Ms
{
    [Table("MsTask")]
    public class MsTask : BaseEntity
    {
        public enum ManualMeasurementStatusEnum
        { 未上传 = 10, 对列中 = 15, 已上传 = 20, 已合并 = 30 }

        public enum TaskStatus
        {
            未完成 = 0,
            已完成 = 1,
            已停止 = 2,
            已开始 = 3,
            已合并 = 30,
        }

        [Key]
        [Column(TypeName = "uuid")]
        [DatabaseGenerated(DatabaseGeneratedOption.None)]
        public Guid TaskId { get; set; }

        /// <summary>
        /// 项目Id
        /// </summary>
        [Column(TypeName = "uuid")]
        [Required]
        public Guid ProjectId { get; set; }

        /// <summary>
        /// 设备Id
        /// </summary>
        [Column(TypeName = "varchar(64)")]
        public string RobotId { get; set; }

        /// <summary>
        /// UserId
        /// </summary>
        [Column(TypeName = "uuid")]
        [Required]
        public Guid UserId { get; set; }

        /// <summary>
        /// 楼栋
        /// </summary>
        [Column(TypeName = "varchar(32)")]
        [Required]
        public string BuildingBlock { get; set; }

        /// <summary>
        /// 楼层
        /// </summary>
        [Column(TypeName = "varchar(32)")]
        [Required]
        public string BuildingFloor { get; set; }

        /// <summary>
        /// 户数
        /// </summary>
        [Column(TypeName = "varchar(32)")]
        public string HouseHolds { get; set; }

        /// <summary>
        /// HouseMap
        /// </summary>
        [Column(TypeName = "uuid")]
        [Required]
        public Guid HouseMapId { get; set; }

        [Required]
        [Column(TypeName = "uuid")]
        public Guid ProjectStandardId { get; set; }

        [Required]
        [Column(TypeName = "varchar(32)")]
        public string Craft { get; set; }

        /// <summary>
        /// 状态
        /// </summary>
        [Column(TypeName = "int4")]
        [Required]
        public TaskStatus Status { get; set; }

        /// <summary>
        /// 任务类型
        /// </summary>
        [Column(TypeName = "int4")]
        [DefaultValue(0)]
        public TaskTypeEnum TaskType { get; set; }

        /// <summary>
        /// 户型图点信息
        /// </summary>
        [Column(TypeName = "text")]
        public string HouseMapPoints { get; set; }

        /// <summary>
        /// 使用的标准
        /// </summary>
        [Column(TypeName = "text")]
        public string UseStandards { get; set; }

        /// <summary>
        /// 标准
        /// </summary>
        [Column(TypeName = "text")]
        public string UsestandardAllInfo { get; set; }

        /// <summary>
        /// 备注
        /// </summary>
        [Column(TypeName = "varchar(500)")]
        public string Remarks { get; set; }

        /// <summary>
        /// 支持的标准
        /// </summary>
        [Column(TypeName = "varchar(32)")]
        public string SupportStandard { get; set; }

        //[ForeignKey("RobotId")]
        //public virtual MsRobot MsRobot { get; set; }
        [ForeignKey("ProjectStandardId")]
        public virtual MsProjectStandard MsProjectStandard { get; set; }

        [ForeignKey("ProjectId")]
        public virtual MsProject MsProject { get; set; }

        [ForeignKey("UserId")]
        public virtual SysUser SysUser { get; set; }

        [ForeignKey("HouseMapId")]
        public virtual MsHouseMap MsHouseMap { get; set; }

        /// <summary>
        /// 是否为新建任务
        /// </summary>
        [Column(TypeName = "bool")]
        public bool IsNew { get; set; } = true;

        [Column(TypeName = "varchar(500)")]
        public string TaskName { get; set; }

        [Column(TypeName = "int4")]
        public int? TaskNameNo { get; set; } = 0;

        [Column(TypeName = "varchar(500)")]
        public string UnqualifiedIndexList { get; set; }

        /// <summary>
        /// t点云已经删除,f点云未删除
        /// </summary>
        [Column(TypeName = "bool")]
        public bool DotCloudDeleted { get; set; }

        /// <summary>
        /// 任务属性
        /// </summary>
        [Column(TypeName = "varchar(10)")]
        public string TaskProperty { get; set; }

        /// <summary>
        /// 任务属性
        /// </summary>
        [Column(TypeName = "varchar(255)")]
        public string HouseType { get; set; }

        [Column(TypeName = "uuid")]
        public Guid AlgorithmParamTemplateGuid { get; set; }

        [Column(TypeName = "varchar(255)")]
        public string AlgorithmParamTemplateName { get; set; }

        /// <summary>
        /// 是否移动端录入人工测量项
        /// </summary>
        [Column(TypeName = "bool")]
        public bool IsMobileInputManualMeasurement { get; set; }

        /// <summary>
        /// 人工测量员用户Id
        /// </summary>
        [Column(TypeName = "uuid")]
        public Guid? MobileInputUserGuid { get; set; }

        /// <summary>
        /// 人工测量员名称
        /// </summary>
        [Column(TypeName = "varchar(500)")]
        public string MobileInputUserName { get; set; }

        /// <summary>
        /// 人工测量项状态
        /// </summary>
        [Column(TypeName = "int4")]
        public ManualMeasurementStatusEnum ManualMeasurementStatus { get; set; }

        [Column(TypeName = "timestamp(0)")]
        public DateTime? UploadDate { get; set; }

        [Column(TypeName = "timestamp(0)")]
        public DateTime? DownloadDate { get; set; }

        [Column(TypeName = "json")]
        public string JsonResultFilePath { get; set; }

        /// <summary>
        /// 任务执行类型，‘1’：一键测量（采算），‘2’：只采
        /// </summary>
        [Column(TypeName = "varchar(5)")]
        public string TaskExecutionType { get; set; }

        /// <summary>
        /// 任务分类，0：实测实量任务，1:机器人任务；2:建模任务；3:排版任务；4:外立面任务
        /// </summary>
        [Column(TypeName = "varchar(10)")]
        public string MeasureType { get; set; }

        /// <summary>
        /// 任务模板工艺类型
        /// </summary>
        public TemplateCraftEnum? TemplateCraft { set; get; }

        /// <summary>
        /// 机器人，0：天花，1：螺杆洞，2：内墙 --- 多个用“|”分隔
        /// </summary>
        public string RobotCategory { set; get; }

        /// <summary>
        /// 内墙版本号，可选：1.2,1.3，默认1.2
        /// </summary>
        public string InnerWallRobotVersion { set; get; }

        /// <summary>
        /// 二次结构类型：无：0，砌体：1，墙板：2，砌体和墙板：3
        /// </summary>
        public SecondaryStructureTypeEnum SecondaryStructureType { set; get; }

        /// <summary>
        /// 测量应用：0平板端，1小程序
        /// </summary>
 		public MeasureAPPEnum MeasureAPP { get; set; }

        /// <summary>
        /// 靠尺设置
        /// </summary>
        public RulerModeType RulerMode { get; set; }
    }
}